package outbound.shipping.dataObjects
{
	import common.utils.DateManager;
	
	import mx.collections.ArrayCollection;
	
	[Bindable]
	public class ShipmentHeaderDO
	{
		public var INTERNAL_SHIPMENT_NUM:Number = 0;
		public var WAREHOUSE:String = "";
		public var COMPANY:String = "";
		public var INTERNAL_LOAD_NUM:Number = 0;
		public var SHIPMENT_ID:String = "";
		public var ERP_ORDER:String = "";
		public var LEADING_STS:Number = 100;
		public var TRAILING_STS:Number = 100;
		public var SHIPMENT_TYPE:String = "";
		public var ROUTE:String = "";
		public var SHIP_TO:String = "";
		public var SHIP_TO_NAME:String = "";
		public var SHIP_TO_ADDRESS1:String = "";
		public var SHIP_TO_ADDRESS2:String = "";
		public var SHIP_TO_CITY:String = "";
		public var SHIP_TO_STATE:String = "";
		public var SHIP_TO_COUNTRY:String = "";
		public var SHIP_TO_POSTAL_CODE:String = "";
		public var SHIP_TO_ATTENTION_TO:String = "";
		public var SHIP_TO_PHONE_NUM:String = "";
		public var SHIP_TO_FAX_NUM:String = "";
		public var SHIP_TO_EMAIL_ADDRESS:String = "";
		public var PRIORITY:String = "10";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();
		public var REQUESTED_DELIVERY_DATE:String = DateManager.GetTodayString();
		public var REQUESTED_DELIVERY_TYPE:String = "";
		public var SCHEDULED_SHIP_DATE:String = DateManager.GetTodayString();
		public var ACTUAL_SHIP_DATE_TIME:String = DateManager.GetTodayString();
		public var ACTUAL_DELIVERY_DATE_TIME:String = DateManager.GetTodayString();
		public var DELIVERY_NOTE:String = "";
		public var REJECTION_NOTE:String = "";
		public var INTERNAL_WAVE_NUM:Number = 0;
		public var ALLOCATE_COMPLETE:String = "";
		
		public function ShipmentHeaderDO(){
			
		}
		
		public function Init(xmlObj:XML):void
		{			
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object				
					this[itemProp.name()] = itemProp;
				}
			}
		}

		public function ToXML():XML{
			var xmlObj:XML = 
				<SHIPMENT_HEADER>
					<INTERNAL_SHIPMENT_NUM>{INTERNAL_SHIPMENT_NUM}</INTERNAL_SHIPMENT_NUM>
					<WAREHOUSE>{WAREHOUSE}</WAREHOUSE>
					<COMPANY>{COMPANY}</COMPANY>
					<INTERNAL_LOAD_NUM>{INTERNAL_LOAD_NUM}</INTERNAL_LOAD_NUM>
					<SHIPMENT_ID>{SHIPMENT_ID}</SHIPMENT_ID>
					<ERP_ORDER>{ERP_ORDER}</ERP_ORDER>
					<LEADING_STS>{LEADING_STS}</LEADING_STS>
					<TRAILING_STS>{TRAILING_STS}</TRAILING_STS>
					<SHIPMENT_TYPE>{SHIPMENT_TYPE}</SHIPMENT_TYPE>
					<ROUTE>{ROUTE}</ROUTE>
					<SHIP_TO>{SHIP_TO}</SHIP_TO>
					<SHIP_TO_NAME>{SHIP_TO_NAME}</SHIP_TO_NAME>
					<SHIP_TO_ADDRESS1>{SHIP_TO_ADDRESS1}</SHIP_TO_ADDRESS1>
					<SHIP_TO_ADDRESS2>{SHIP_TO_ADDRESS2}</SHIP_TO_ADDRESS2>
					<SHIP_TO_CITY>{SHIP_TO_CITY}</SHIP_TO_CITY>
					<SHIP_TO_STATE>{SHIP_TO_STATE}</SHIP_TO_STATE>
					<SHIP_TO_COUNTRY>{SHIP_TO_COUNTRY}</SHIP_TO_COUNTRY>
					<SHIP_TO_POSTAL_CODE>{SHIP_TO_POSTAL_CODE}</SHIP_TO_POSTAL_CODE>
					<SHIP_TO_ATTENTION_TO>{SHIP_TO_ATTENTION_TO}</SHIP_TO_ATTENTION_TO>
					<SHIP_TO_PHONE_NUM>{SHIP_TO_PHONE_NUM}</SHIP_TO_PHONE_NUM>
					<SHIP_TO_FAX_NUM>{SHIP_TO_FAX_NUM}</SHIP_TO_FAX_NUM>
					<SHIP_TO_EMAIL_ADDRESS>{SHIP_TO_EMAIL_ADDRESS}</SHIP_TO_EMAIL_ADDRESS>
					<PRIORITY>{PRIORITY}</PRIORITY>
					<USER_STAMP>{USER_STAMP}</USER_STAMP>
					<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
					<REQUESTED_DELIVERY_DATE>{REQUESTED_DELIVERY_DATE}</REQUESTED_DELIVERY_DATE>
					<REQUESTED_DELIVERY_TYPE>{REQUESTED_DELIVERY_TYPE}</REQUESTED_DELIVERY_TYPE>
					<SCHEDULED_SHIP_DATE>{SCHEDULED_SHIP_DATE}</SCHEDULED_SHIP_DATE>
					<ACTUAL_SHIP_DATE_TIME>{ACTUAL_SHIP_DATE_TIME}</ACTUAL_SHIP_DATE_TIME>
					<ACTUAL_DELIVERY_DATE_TIME>{ACTUAL_DELIVERY_DATE_TIME}</ACTUAL_DELIVERY_DATE_TIME>
					<DELIVERY_NOTE>{DELIVERY_NOTE}</DELIVERY_NOTE>
					<REJECTION_NOTE>{REJECTION_NOTE}</REJECTION_NOTE>
					<ALLOCATE_COMPLETE>{ALLOCATE_COMPLETE}</ALLOCATE_COMPLETE>
				</SHIPMENT_HEADER>;
				
			return xmlObj;			
		}
		

		public static function getShipmentHeaders(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var shpHdr:ShipmentHeaderDO = new ShipmentHeaderDO();
				shpHdr.Init(xml);
				ac.addItem(shpHdr);
			}
			return ac;
		}		
	}
}